package com.ybfenpan.controller.admin.center;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ybfenpan.controller.core.BaseController;
import com.ybfenpan.model.center.RequestCenter;
import com.ybfenpan.service.center.RequestCenterService;
import com.ybfenpan.taglib.pagetag.Pagination;
import com.ybfenpan.utils.MapUtil;

/**
 * Created by Administrator on 2016/3/25.
 */
@Controller
public class RequestCenterListController extends BaseController {

	@Resource
	private RequestCenterService requestCenterService;

	@RequestMapping("admin/center/requestCenterList.shtml")
	public String list(HttpServletRequest request) throws Exception {
		HashMap formMap = getParameterMap(request);

		formMap.put("where", " 1=1 and a.state=10 and b.accountCenter='F' ");
		Pagination page = requestCenterService.queryForPageList("requestCenterForPage", formMap);
		request.setAttribute(Pagination.pageBeanName, page);
		return "admin/center/requestCenterList";
	}

	@RequestMapping("admin/center/requestCenterNo.shtml")
	public String delete(HttpServletRequest request) throws Exception {
		Map formMap = getParameterMap(request);
		int id = MapUtil.getIntValue(formMap, "id");
		if (id > 0) {
			RequestCenter one = (RequestCenter) this.requestCenterService.getByKey(id);
			one.setState(30);
			one.setCenterLevel(0);
			requestCenterService.update(one);
		}
		return "redirect:requestCenterList.shtml";

	}
}
